<template>
  <div class="AddOrUpdate_main add_container showDetail" :class="showKey.type">
    <div class="main_main">
      <el-form ref="form" :model="formData" :rules="rules" :inline="true">

        <div
          v-for="(item2,index2) in showKey.keys"
          :key="'index2'+index2"
          :class="getClass(item2)"
        >
          <el-form-item v-if="item2.type=='form'" :label="item2.name">
            <div v-if="!showData[item2.key]&&showData[item2.key]!==0&&showData[item2.key]!=='0'" class="shows noData">暂无</div>
            <div v-else-if="item2.key=='status'" class="shows">{{ showData[item2.key]=='1'||showData[item2.key]==1?'启用':'停用' }}</div>
            <div v-else class="shows">{{ showData[item2.key] }}</div>
          </el-form-item>
          <el-form-item v-if="item2.type=='file'" :label="item2.name">
            <FileManageFull
              :file-names="showData[item2.fileName]"
              :file-real-names="showData[item2.fileRealName]"
              :file-urls="showData[item2.fileUrl]"
              :row-index="1"
              :readonly="true"
              @fileName="setFileName"
            />
          </el-form-item>

          <div v-if="item2.type=='table'" ref="table_container" class="table_container draggableTable addRow_table">
            <el-table
              ref="table"
              :data="showData[item2.key]"
              stripe
              border
              row-key="id"
              style="width: 99.9%"
            >
              <el-table-column type="expand">
                <template slot-scope="props">
                  <el-form label-position="left" class="expand_container">
                    <el-form-item label="点检结果" class="expand_radio">
                      <div class="show">
                        <svg-icon v-if="props.row.result==1" icon-class="勾" />
                        <svg-icon v-else-if="props.row.result==0" icon-class="叉" />
                        <div v-else>暂无</div>
                      </div>
                    </el-form-item>
                    <el-form-item label="现场照片" class="expand_file file double">
                      <FileManageFull
                        :file-names="props.row.docName"
                        :file-real-names="props.row.docRealName"
                        :file-urls="props.row.docUrl"
                        :row-index="props.$index"
                        :readonly="true"
                        @fileName="setFileName"
                      />
                    </el-form-item>
                    <el-form-item label="点检记录" class="double">
                      <div class="show">{{ props.row.description?props.row.description:'暂无' }}</div>
                    </el-form-item>
                    <el-form-item label="备注" class="double">
                      <div class="show">{{ props.row.remark?props.row.remark:'暂无' }}</div>
                    </el-form-item>
                  </el-form>
                </template>
              </el-table-column>
              <el-table-column prop="sort" label="序号" width="70">
                <template slot-scope="scope">
                  <div v-if="!scope.row.isAdd">{{ scope.row.sort }}</div>
                  <div v-else />
                </template>
              </el-table-column>
              <el-table-column prop="name" label="点检项目">
                <template slot-scope="scope">
                  <DivTextarea :row-value="scope.row.name" />
                  <!-- <el-input v-model="scope.row.name" style="margin:10px 0;" type="textarea" autosize readonly /> -->
                </template>
              </el-table-column>
              <el-table-column prop="content" label="点检内容">
                <template slot-scope="scope">
                  <DivTextarea :row-value="scope.row.content" />
                  <!-- <el-input v-model="scope.row.content" style="margin:10px 0;" type="textarea" autosize readonly /> -->
                </template>
              </el-table-column>
              <el-table-column prop="way" label="点检方式">
                <template slot-scope="scope">
                  <DivTextarea :row-value="scope.row.way" />
                  <!-- <el-input v-model="scope.row.way" style="margin:10px 0;" type="textarea" autosize readonly /> -->
                </template>
              </el-table-column>
              <el-table-column prop="time" label="时间 ( S )" width="80">
                <template slot-scope="scope">
                  <DivTextarea :row-value="scope.row.time" />
                  <!-- <el-input v-model="scope.row.time" style="margin:10px 0;" type="textarea" autosize readonly /> -->
                </template>
              </el-table-column>
              <el-table-column prop="criterion" label="判断标准">
                <template slot-scope="scope">
                  <DivTextarea :row-value="scope.row.criterion" />
                  <!-- <el-input v-model="scope.row.criterion" style="margin:10px 0;" type="textarea" autosize readonly /> -->
                </template>
              </el-table-column>
              <el-table-column
                label="附件"
                min-width="120"
              >
                <template slot-scope="scope">
                  <FileManage
                    :file-names.sync="scope.row.fileName"
                    :file-real-names.sync="scope.row.fileRealName"
                    :file-urls.sync="scope.row.fileUrl"
                    :readonly="true"
                    class="accessory"
                  />
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>

      </el-form>
    </div>

  </div>
</template>

<script>
import DivTextarea from '@/components/JLink/common/DivTextarea.vue'
export default {
  name: 'ShowDetailOld',
  components: {
    DivTextarea
  },
  props: {
    layerid: {},
    id: {},
    showKey: {},
    showData: {}
  },
  data() {
    return {
      formData: {
      },
      rules: {
      },
      tableHeight: '350'
    }
  },
  mounted() {
  },
  methods: {// 表格拖动排序

    cancel() {
      this.$layer.close(this.layerid)// 关闭弹框
    },
    setFileName(...data) {
      this.tableData[data[3]].fileName = data[0]
      this.tableData[data[3]].fileRealName = data[1]
      this.tableData[data[3]].fileUrl = data[2]
    },
    getClass(item) {
      let res = ''
      if (item.type == 'form') {
        res += 'showItem'
        if (item.length && item.length == 'double') {
          res += ' doubles'
        }
      } else if (item.type == 'file') {
        res += 'showItem doubles'
      } else {
        res += 'showTable'
      }

      return res
    }
  }
}
</script>

<style lang="less" scoped>
/deep/ .el-textarea__inner{
  border: none !important;
  background: none;
}
.accessory {
  color: #387bfc
}
.main_main{
  .el-form{
    height: 100%;
    align-content: flex-start;

    .showItem{
      margin-left: 20px;
      margin-right: 20px;
      width: calc(33.33% - 40px);
    }

    /deep/ .el-form-item{
      width: 100%;
      border-bottom: 1px solid rgba(105,105,105,0.2);
      margin-left: 0;
      margin-right: 0;

      .el-form-item__label:before{
        content: none;
      }
      .el-form-item__label{
        color: #1F51B3;
        font-size: 15px;
      }
      .el-form-item__content{
        word-break: break-all;
        color: #333333;
        font-size: 15px;
        flex: 1;
        width: unset;
        margin-right: 0px;
      }
    }
    .doubles{
      width: calc(100% - 40px);
      //.show{
      //  overflow: hidden;
      //  text-overflow: ellipsis;
      //  display: -webkit-box;
      //  -webkit-line-clamp: 2;
      //  -webkit-box-orient: vertical;
      //}
    }
  }
  .showTable{
    width: 100%;
  }
}

.column_one{
  .showItem{
    width: 100% !important;
  }
}
.noData{
  color: #c0c4cc;
}
.shows{
  height: fit-content !important;
  padding-top: 10px;
  padding-bottom: 10px;
}

.show{
  height: fit-content !important;
  min-height: 50px;
  padding-top: 10px;
  padding-bottom: 10px;
}
.FileManageFull_container{
  padding-top: 10px;
}

.table_container{
  /deep/ .el-form-item{
    border-bottom: 0 !important;
    width: calc(100% - 40px) !important;
    margin-left: 20px !important;
    margin-right: 20px !important;
    .el-form-item__label:before{
      content: none;
    }
    .el-form-item__content{
      word-break: break-all;
      flex: 1;
      width: unset;
      margin-right: 0px;
    }
  }
}
.el-table {
  font-size: 15px;
}
</style>
